<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/*! jwsjs-2.0.2 (c) 2010-2015 Kenji Urushima | kjur.github.com/jsrsasign/license
<span class='line'>  2</span>  */</span><span class="WHIT">
<span class='line'>  3</span> </span><span class="COMM">/*
<span class='line'>  4</span>  * jwsjs.js - JSON Web Signature JSON Serialization (JWSJS) Class
<span class='line'>  5</span>  *
<span class='line'>  6</span>  * version: 2.0.2 (2015 May 29)
<span class='line'>  7</span>  *
<span class='line'>  8</span>  * Copyright (c) 2010-2015 Kenji Urushima (kenji.urushima@gmail.com)
<span class='line'>  9</span>  *
<span class='line'> 10</span>  * This software is licensed under the terms of the MIT License.
<span class='line'> 11</span>  * http://kjur.github.com/jsrsasign/license/
<span class='line'> 12</span>  *
<span class='line'> 13</span>  * The above copyright and license notice shall be 
<span class='line'> 14</span>  * included in all copies or substantial portions of the Software.
<span class='line'> 15</span>  */</span><span class="WHIT">
<span class='line'> 16</span> 
<span class='line'> 17</span> </span><span class="COMM">/**
<span class='line'> 18</span>  * @fileOverview
<span class='line'> 19</span>  * @name jwsjs-2.0.js
<span class='line'> 20</span>  * @author Kenji Urushima kenji.urushima@gmail.com
<span class='line'> 21</span>  * @version 2.0.2 (2015 May 29)
<span class='line'> 22</span>  * @since jsjws 1.2, jsrsasign 4.8.0
<span class='line'> 23</span>  * @license &lt;a href="http://kjur.github.io/jsrsasign/license/">MIT License&lt;/a>
<span class='line'> 24</span>  */</span><span class="WHIT">
<span class='line'> 25</span> 
<span class='line'> 26</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">KJUR</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 27</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">KJUR.jws</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">KJUR.jws</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">KJUR.jws</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 28</span> 
<span class='line'> 29</span> </span><span class="COMM">/**
<span class='line'> 30</span>  * JSON Web Signature JSON Serialization (JWSJS) class.&lt;br/>
<span class='line'> 31</span>  * @class JSON Web Signature JSON Serialization (JWSJS) class
<span class='line'> 32</span>  * @name KJUR.jws.JWSJS
<span class='line'> 33</span>  * @property {array of String} aHeader array of Encoded JWS Headers
<span class='line'> 34</span>  * @property {String} sPayload Encoded JWS payload
<span class='line'> 35</span>  * @property {array of String} aSignature array of Encoded JWS signature value
<span class='line'> 36</span>  * @author Kenji Urushima
<span class='line'> 37</span>  * @version 1.0 (18 May 2012)
<span class='line'> 38</span>  * @requires base64x.js, json-sans-eval.js, jws.js and jsrsasign library
<span class='line'> 39</span>  * @see &lt;a href="http://kjur.github.com/jsjws/">'jwjws'(JWS JavaScript Library) home page http://kjur.github.com/jsjws/&lt;/a>
<span class='line'> 40</span>  * @see &lt;a href="http://kjur.github.com/jsrsasigns/">'jwrsasign'(RSA Sign JavaScript Library) home page http://kjur.github.com/jsrsasign/&lt;/a>
<span class='line'> 41</span>  * @see &lt;a href="http://tools.ietf.org/html/draft-jones-json-web-signature-json-serialization-01">IETF I-D JSON Web Signature JSON Serialization (JWS-JS) specification&lt;/a>
<span class='line'> 42</span>  */</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="NAME">KJUR.jws.JWSJS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ns1</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.jws.JWS</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 45</span> 
<span class='line'> 46</span> </span><span class="WHIT">    </span><span class="NAME">this.aHeader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="WHIT">    </span><span class="NAME">this.sPayload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="WHIT">    </span><span class="NAME">this.aSignature</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 49</span> 
<span class='line'> 50</span> </span><span class="WHIT">    </span><span class="COMM">// == initialize ===================================================================</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 52</span>      * (re-)initialize this object.&lt;br/>
<span class='line'> 53</span>      * @name init
<span class='line'> 54</span>      * @memberOf KJUR.jws.JWSJS
<span class='line'> 55</span>      * @function
<span class='line'> 56</span>      */</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT">    </span><span class="NAME">this.init</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT">		</span><span class="NAME">this.aHeader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">		</span><span class="NAME">this.sPayload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT">		</span><span class="NAME">this.aSignature</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 62</span> 
<span class='line'> 63</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 64</span>      * (re-)initialize and set first signature with JWS.&lt;br/>
<span class='line'> 65</span>      * @name initWithJWS
<span class='line'> 66</span>      * @memberOf KJUR.jws.JWSJS
<span class='line'> 67</span>      * @param {String} sJWS JWS signature to set
<span class='line'> 68</span>      * @function
<span class='line'> 69</span>      */</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">    </span><span class="NAME">this.initWithJWS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sJWS</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">		</span><span class="NAME">this.init</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 72</span> 
<span class='line'> 73</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">jws</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">KJUR.jws.JWS</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">		</span><span class="NAME">jws.parseJWS</span><span class="PUNC">(</span><span class="NAME">sJWS</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 75</span> 
<span class='line'> 76</span> </span><span class="WHIT">		</span><span class="NAME">this.aHeader.push</span><span class="PUNC">(</span><span class="NAME">jws.parsedJWS.headB64U</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">		</span><span class="NAME">this.sPayload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">jws.parsedJWS.payloadB64U</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT">		</span><span class="NAME">this.aSignature.push</span><span class="PUNC">(</span><span class="NAME">jws.parsedJWS.sigvalB64U</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 80</span> 
<span class='line'> 81</span> </span><span class="WHIT">    </span><span class="COMM">// == add signature ===================================================================</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'> 83</span>      * add a signature to existing JWS-JS by Header and PKCS1 private key.&lt;br/>
<span class='line'> 84</span>      * @name addSignatureByHeaderKey
<span class='line'> 85</span>      * @memberOf KJUR.jws.JWSJS
<span class='line'> 86</span>      * @function
<span class='line'> 87</span>      * @param {String} sHead JSON string of JWS Header for adding signature.
<span class='line'> 88</span>      * @param {String} sPemPrvKey string of PKCS1 private key
<span class='line'> 89</span>      */</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">    </span><span class="NAME">this.addSignatureByHeaderKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sHead</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sPemPrvKey</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sPayload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64utoutf8</span><span class="PUNC">(</span><span class="NAME">this.sPayload</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 92</span> 
<span class='line'> 93</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">jws</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">KJUR.jws.JWS</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sJWS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">jws.generateJWSByP1PrvKey</span><span class="PUNC">(</span><span class="NAME">sHead</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sPayload</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sPemPrvKey</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT">  
<span class='line'> 96</span> 		</span><span class="NAME">this.aHeader.push</span><span class="PUNC">(</span><span class="NAME">jws.parsedJWS.headB64U</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">		</span><span class="NAME">this.aSignature.push</span><span class="PUNC">(</span><span class="NAME">jws.parsedJWS.sigvalB64U</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 99</span> 
<span class='line'>100</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>101</span>      * add a signature to existing JWS-JS by Header, Payload and PKCS1 private key.&lt;br/>
<span class='line'>102</span>      * This is to add first signature to JWS-JS object.
<span class='line'>103</span>      * @name addSignatureByHeaderPayloadKey
<span class='line'>104</span>      * @memberOf KJUR.jws.JWSJS
<span class='line'>105</span>      * @function
<span class='line'>106</span>      * @param {String} sHead JSON string of JWS Header for adding signature.
<span class='line'>107</span>      * @param {String} sPayload string of JWS Payload for adding signature.
<span class='line'>108</span>      * @param {String} sPemPrvKey string of PKCS1 private key
<span class='line'>109</span>      */</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">    </span><span class="NAME">this.addSignatureByHeaderPayloadKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sHead</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sPayload</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sPemPrvKey</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">jws</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">KJUR.jws.JWS</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sJWS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">jws.generateJWSByP1PrvKey</span><span class="PUNC">(</span><span class="NAME">sHead</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sPayload</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sPemPrvKey</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">  
<span class='line'>114</span> 		</span><span class="NAME">this.aHeader.push</span><span class="PUNC">(</span><span class="NAME">jws.parsedJWS.headB64U</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">		</span><span class="NAME">this.sPayload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">jws.parsedJWS.payloadB64U</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">		</span><span class="NAME">this.aSignature.push</span><span class="PUNC">(</span><span class="NAME">jws.parsedJWS.sigvalB64U</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>118</span> 
<span class='line'>119</span> </span><span class="WHIT">    </span><span class="COMM">// == verify signature ===================================================================</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>121</span>      * verify JWS-JS object with array of certificate string.&lt;br/>
<span class='line'>122</span>      * @name verifyWithCerts
<span class='line'>123</span>      * @memberOf KJUR.jws.JWSJS
<span class='line'>124</span>      * @function
<span class='line'>125</span>      * @param {array of String} aCert array of string for X.509 PEM certificate.
<span class='line'>126</span>      * @return 1 if signature is valid.
<span class='line'>127</span>      * @throw if JWS-JS signature is invalid.
<span class='line'>128</span>      */</span><span class="WHIT">
<span class='line'>129</span> </span><span class="WHIT">    </span><span class="NAME">this.verifyWithCerts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">aCert</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.aHeader.length</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">aCert.length</span><span class="PUNC">)</span><span class="WHIT"> 
<span class='line'>131</span> 			</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"num headers does not match with num certs"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.aSignature.length</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">aCert.length</span><span class="PUNC">)</span><span class="WHIT"> 
<span class='line'>133</span> 			</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"num signatures does not match with num certs"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>134</span> 
<span class='line'>135</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">payload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.sPayload</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">errMsg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">aCert.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">cert</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">aCert</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">header</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.aHeader</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.aSignature</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sJWS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">header</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"."</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">payload</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"."</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sig</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>142</span> 
<span class='line'>143</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">jws</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">KJUR.jws.JWS</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">			</span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">				</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">jws.verifyJWSByPemX509Cert</span><span class="PUNC">(</span><span class="NAME">sJWS</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">cert</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">				</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT">					</span><span class="NAME">errMsg</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"th signature unmatch. "</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT">				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>149</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>150</span> </span><span class="WHIT">				</span><span class="NAME">errMsg</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"th signature fail("</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">ex</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"). "</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>153</span> 
<span class='line'>154</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">errMsg</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>156</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT">			</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">errMsg</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>158</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>160</span> 
<span class='line'>161</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>162</span>      * read JWS-JS string.&lt;br/>
<span class='line'>163</span>      * @name raedJWSJS
<span class='line'>164</span>      * @memberOf KJUR.jws.JWSJS
<span class='line'>165</span>      * @function
<span class='line'>166</span>      * @param {String} string of JWS-JS to load.
<span class='line'>167</span>      * @throw if sJWSJS is malformed or not JSON string.
<span class='line'>168</span>      */</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">    </span><span class="NAME">this.readJWSJS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sJWSJS</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>170</span> </span><span class="WHIT">		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">oJWSJS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ns1.readSafeJSONString</span><span class="PUNC">(</span><span class="NAME">sJWSJS</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>171</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">oJWSJS</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"argument is not JSON string: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sJWSJS</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>172</span> 
<span class='line'>173</span> </span><span class="WHIT">		</span><span class="NAME">this.aHeader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">oJWSJS.headers</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>174</span> </span><span class="WHIT">		</span><span class="NAME">this.sPayload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">oJWSJS.payload</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>175</span> </span><span class="WHIT">		</span><span class="NAME">this.aSignature</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">oJWSJS.signatures</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>176</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>177</span> 
<span class='line'>178</span> </span><span class="WHIT">    </span><span class="COMM">// == utility ===================================================================</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>180</span>      * get JSON object for this JWS-JS object.&lt;br/>
<span class='line'>181</span>      * @name getJSON
<span class='line'>182</span>      * @memberOf KJUR.jws.JWSJS
<span class='line'>183</span>      * @function
<span class='line'>184</span>      */</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">    </span><span class="NAME">this.getJSON</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="STRN">"headers"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">this.aHeader</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">				 </span><span class="STRN">"payload"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">this.sPayload</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>188</span> </span><span class="WHIT">				 </span><span class="STRN">"signatures"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">this.aSignature</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT"> 
<span class='line'>189</span>     </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>190</span> 
<span class='line'>191</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>192</span>      * check if this JWS-JS object is empty.&lt;br/>
<span class='line'>193</span>      * @name isEmpty
<span class='line'>194</span>      * @memberOf KJUR.jws.JWSJS
<span class='line'>195</span>      * @function
<span class='line'>196</span>      * @return 1 if there is no signatures in this object, otherwise 0.
<span class='line'>197</span>      */</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">    </span><span class="NAME">this.isEmpty</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.aHeader.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> 
<span class='line'>200</span> 		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>202</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>203</span> 
<span class='line'>204</span> </span></pre></body></html>